package org.southyin.test;

public class Practice02 {
    public static void main(String[] args) {
        // 写一个方法：判断一个字符串中，某字符出现的所有位置
        String str = "abcdabcdeabc";
        String child = "ab";
        int index = str.indexOf(child);
        int temp = index;
        while (index != -1) {
            System.out.println(temp + 1);
            str = str.substring(index + child.length());
            index = str.indexOf(child);
            temp += (index + child.length());
        }

//        while (index != -1) {
//            System.out.println(index + 1);
//            index = str.indexOf(child, index + 1);
//        }
    }
}
